package com.vtech.ont.tdb.portal;

import org.apache.jena.query.Dataset;
import org.apache.jena.tdb.TDBFactory;
import org.apache.jena.tdb.base.file.Location;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Connect to TDB to get dataset
 *
 * @author houzhiwei
 * @date 2017 /7/14 20:17
 * @since 1.0
 */
public class TdbConnection {

    final static Logger log = LoggerFactory.getLogger(TdbConnection.class);

    /**
     * Connect TDB data set.
     *
     * @param tdbPath the tdb path
     * @return dataset
     */
    public static Dataset connect(String tdbPath) {
        Location location = Location.create(tdbPath);
        return TDBFactory.createDataset(location);
    }

    /**
     * Connect TDB data set use assemble file.
     *
     * @param assemblerPath the tdb assembler file path
     * @return the dataset
     */
    public static Dataset assembleConnect(String assemblerPath) {
        return TDBFactory.assembleDataset(assemblerPath);
    }
}
